import axios from '@/libs/api'

export const login = ({ userName, password }) => {
  const data = {
    userName,
    password
  }
  return axios.service({
    url: '/login',
    data,
    method: 'post'
  })
}

export const getUserInfo = () => {
  return axios.service({
    url: '/user/info',
    // params: {
    //   token
    // },
    method: 'get'
  })
}

export const logout = () => {
  return axios.service({
    url: '/logout',
    method: 'post'
  })
}

export const getUnreadCount = () => {
  return axios.service({
    url: 'SysUserMessage/count',
    method: 'get'
  })
}

export const getMessage = () => {
  return axios.service({
    url: 'SysUserMessage/group',
    method: 'get'
  })
}

export const getContentByMsgId = msgId => {
  return axios.service({
    url: 'SysUserMessage/getMessage',
    method: 'get',
    params: {
      msgId
    }
  })
}

export const hasRead = msg_id => {
  return axios.service({
    url: 'SysUserMessage/saveOrUpdate',
    method: 'post',
    data: {
      id: msg_id,
      readFlag: 'READED'
    }
  })
}

export const removeReaded = msg_id => {
  return axios.service({
    url: 'SysUserMessage/saveOrUpdate',
    method: 'post',
    data: {
      id: msg_id,
      readFlag: 'TRASH'
    }
  })
}

export const restoreTrash = msg_id => {
  return axios.service({
    url: 'SysUserMessage/saveOrUpdate',
    method: 'post',
    data: {
      id: msg_id,
      readFlag: 'READED'
    }
  })
}
